﻿let lastOf vals =
    let N =
        vals
        |> Seq.length
    
    vals
    |> Seq.nth (N-1)
    

let slideRatio width (vals : float seq) =
    vals
    |> Seq.windowed width
    |> Seq.map (fun win -> win.[width - 1] / win.[0])


let extract (data : System.String) =
    data.Split('\n')
    |> Seq.map (fun s ->
        s.Split(',')
        |> lastOf
        |> fun s -> System.Double.Parse(s, System.Globalization.NumberFormatInfo.InvariantInfo)
    )


let data_tz = "10/11/2008,0.00061850
10/12/2008,0.0006340
10/13/2008,0.00063350
10/14/2008,0.00061880
10/15/2008,0.00060560
10/16/2008,0.00061750
10/17/2008,0.00062780
10/18/2008,0.00061150
10/19/2008,0.00060480
10/20/2008,0.00060480
10/21/2008,0.00060840
10/22/2008,0.00059990
10/23/2008,0.00060620
10/24/2008,0.00061810
10/25/2008,0.00062620
10/26/2008,0.00062620
10/27/2008,0.00063040
10/28/2008,0.00062720
10/29/2008,0.00062730
10/30/2008,0.00061380
10/31/2008,0.00060
11/01/2008,0.00061560
11/02/2008,0.00062960
11/03/2008,0.00062830
11/04/2008,0.00062190
11/05/2008,0.00062610
11/06/2008,0.0006250
11/07/2008,0.00063250
11/08/2008,0.00064410
11/09/2008,0.00065260
11/10/2008,0.00065250
11/11/2008,0.00064160
11/12/2008,0.00064440
11/13/2008,0.00064590
11/14/2008,0.00065470
11/15/2008,0.00064760
11/16/2008,0.00065270
11/17/2008,0.00065220
11/18/2008,0.00064890
11/19/2008,0.00064890
11/20/2008,0.00064790
11/21/2008,0.00064870
11/22/2008,0.00064950
11/23/2008,0.00064560
11/24/2008,0.00064550
11/25/2008,0.00064430
11/26/2008,0.00062840
11/27/2008,0.00062430
11/28/2008,0.00062330
11/29/2008,0.00062390
11/30/2008,0.00062420
12/01/2008,0.00062410
12/02/2008,0.00062880
12/03/2008,0.00062080
12/04/2008,0.00061960
12/05/2008,0.00061780
12/06/2008,0.0006190
12/07/2008,0.00061920
12/08/2008,0.00061910
12/09/2008,0.00061110
12/10/2008,0.00061080
12/11/2008,0.00060790
12/12/2008,0.00059830
12/13/2008,0.00058960
12/14/2008,0.00058680
12/15/2008,0.00058690
12/16/2008,0.00058620
12/17/2008,0.00056760
12/18/2008,0.00055460
12/19/2008,0.00054410
12/20/2008,0.00055040
12/21/2008,0.00055790
12/22/2008,0.00055790
12/23/2008,0.00056310
12/24/2008,0.00055180
12/25/2008,0.00055060
12/26/2008,0.00054920
12/27/2008,0.00054760
12/28/2008,0.00054840
12/29/2008,0.00054840
12/30/2008,0.00054380
12/31/2008,0.00054480
01/01/2009,0.00054950
01/02/2009,0.0005530
01/03/2009,0.00055410
01/04/2009,0.00055170
01/05/2009,0.00055170
01/06/2009,0.00055550
01/07/2009,0.00056570
01/08/2009,0.00055990
01/09/2009,0.00055780
01/10/2009,0.00055320
01/11/2009,0.00054510
01/12/2009,0.00054510
01/13/2009,0.00056820
01/14/2009,0.00056550
01/15/2009,0.00058510
01/16/2009,0.00059030
01/17/2009,0.00058120
01/18/2009,0.00058350
01/19/2009,0.00058320
01/20/2009,0.00056580
01/21/2009,0.00057560
01/22/2009,0.00056270
01/23/2009,0.00056790
01/24/2009,0.00056540
01/25/2009,0.00056580
01/26/2009,0.00056580
01/27/2009,0.00055730
01/28/2009,0.0005640
01/29/2009,0.00057770
01/30/2009,0.00059210
01/31/2009,0.00060780
02/01/2009,0.00061550
02/02/2009,0.00061340
02/03/2009,0.00060440
02/04/2009,0.00060290
02/05/2009,0.00060350
02/06/2009,0.0006050
02/07/2009,0.00060150
02/08/2009,0.00060560
02/09/2009,0.00060560
02/10/2009,0.00059190
02/11/2009,0.00059970
02/12/2009,0.00060070
02/13/2009,0.00060110
02/14/2009,0.00059940
02/15/2009,0.00060160
02/16/2009,0.00060170
02/17/2009,0.00059810
02/18/2009,0.0006060
02/19/2009,0.00060650
02/20/2009,0.00059790
02/21/2009,0.00060260
02/22/2009,0.00060190
02/23/2009,0.00060220
02/24/2009,0.00059620
02/25/2009,0.00060440
02/26/2009,0.00060530
02/27/2009,0.00060340
02/28/2009,0.00060630
03/01/2009,0.00060720
03/02/2009,0.00060730
03/03/2009,0.00061570
03/04/2009,0.00061490
03/05/2009,0.00061940
03/06/2009,0.00061940
03/07/2009,0.00062120
03/08/2009,0.00061970
03/09/2009,0.00061970
03/10/2009,0.00062180
03/11/2009,0.00061850
03/12/2009,0.00061490
03/13/2009,0.00061450
03/14/2009,0.00060480
03/15/2009,0.00060620
03/16/2009,0.00060630
03/17/2009,0.00060640
03/18/2009,0.00059210
03/19/2009,0.00059390
03/20/2009,0.00058140
03/21/2009,0.00056880
03/22/2009,0.00056910
03/23/2009,0.00056910
03/24/2009,0.00056830
03/25/2009,0.00056860
03/26/2009,0.00057170
03/27/2009,0.00056550
03/28/2009,0.00056690
03/29/2009,0.00057420
03/30/2009,0.00057430
03/31/2009,0.00058070
04/01/2009,0.00058030
04/02/2009,0.00058140
04/03/2009,0.00057270
04/04/2009,0.00056680
04/05/2009,0.00056550
04/06/2009,0.00056540
04/07/2009,0.00056620
04/08/2009,0.00057230
04/09/2009,0.00057810
04/10/2009,0.00057640
04/11/2009,0.00058470
04/12/2009,0.00058280
04/13/2009,0.00058290
04/14/2009,0.00058070
04/15/2009,0.00057390
04/16/2009,0.00057830
04/17/2009,0.00057820
04/18/2009,0.00058330
04/19/2009,0.00058520
04/20/2009,0.00058520
04/21/2009,0.00058660
04/22/2009,0.00058640
04/23/2009,0.00058390
04/24/2009,0.00058020
04/25/2009,0.00057170
04/26/2009,0.00057120
04/27/2009,0.00057010
04/28/2009,0.00057360
04/29/2009,0.0005830
04/30/2009,0.00057520
05/01/2009,0.00057150
05/02/2009,0.00057540
05/03/2009,0.00057520
05/04/2009,0.00057520
05/05/2009,0.0005730
05/06/2009,0.00057280
05/07/2009,0.00057380
05/08/2009,0.00057330
05/09/2009,0.00057230
05/10/2009,0.00056850
05/11/2009,0.00056840
05/12/2009,0.00056290
05/13/2009,0.00056140
05/14/2009,0.00055550
05/15/2009,0.0005610
05/16/2009,0.00055960
05/17/2009,0.0005630
05/18/2009,0.0005630
05/19/2009,0.00056580
05/20/2009,0.00056150
05/21/2009,0.00055710
05/22/2009,0.00055680
05/23/2009,0.00054910
05/24/2009,0.00054780
05/25/2009,0.00054770
05/26/2009,0.00054930
05/27/2009,0.00055090
05/28/2009,0.00055090
05/29/2009,0.00055210
05/30/2009,0.00054480
05/31/2009,0.00054090
06/01/2009,0.00054090
06/02/2009,0.00053660
06/03/2009,0.00053830
06/04/2009,0.00053860
06/05/2009,0.00054050
06/06/2009,0.00054380
06/07/2009,0.00054390
06/08/2009,0.00054390
06/09/2009,0.00055280
06/10/2009,0.00055670
06/11/2009,0.00055360
06/12/2009,0.00055460
06/13/2009,0.0005520
06/14/2009,0.00055360
06/15/2009,0.00055360
06/16/2009,0.00056020
06/17/2009,0.00056240
06/18/2009,0.00056230
06/19/2009,0.00055950
06/20/2009,0.00055710
06/21/2009,0.00056170
06/22/2009,0.00056160
06/23/2009,0.00055770
06/24/2009,0.00055420
06/25/2009,0.00054970
06/26/2009,0.00055210
06/27/2009,0.00055110
06/28/2009,0.00055110
06/29/2009,0.0005510
06/30/2009,0.0005520
07/01/2009,0.00054820
07/02/2009,0.00054740
07/03/2009,0.00054750
07/04/2009,0.00055370
07/05/2009,0.00055340
07/06/2009,0.00055470
07/07/2009,0.0005520
07/08/2009,0.00055220
07/09/2009,0.00055410
07/10/2009,0.00055310
07/11/2009,0.00055190
07/12/2009,0.0005560
07/13/2009,0.00054580
07/14/2009,0.00055030
07/15/2009,0.00054870
07/16/2009,0.00054460
07/17/2009,0.00054130
07/18/2009,0.00054090
07/19/2009,0.00054460
07/20/2009,0.00054460
07/21/2009,0.00053710
07/22/2009,0.00053650
07/23/2009,0.00053790
07/24/2009,0.00053780
07/25/2009,0.00053710
07/26/2009,0.0005370
07/27/2009,0.0005370
07/28/2009,0.0005360
07/29/2009,0.00053730
07/30/2009,0.00053960
07/31/2009,0.00054330
08/01/2009,0.00053430
08/02/2009,0.00053030
08/03/2009,0.00053030
08/04/2009,0.00053440
08/05/2009,0.00053070
08/06/2009,0.00053280
08/07/2009,0.00053330
08/08/2009,0.00053770
08/09/2009,0.00053680
08/10/2009,0.00053670
08/11/2009,0.00054150
08/12/2009,0.00054140
08/13/2009,0.00054030
08/14/2009,0.00053820
08/15/2009,0.00053870
08/16/2009,0.00053730
08/17/2009,0.00053280
08/18/2009,0.00054630
08/19/2009,0.00054690
08/20/2009,0.00054530
08/21/2009,0.00054130
08/22/2009,0.00053990
08/23/2009,0.00053850
08/24/2009,0.00053850
08/25/2009,0.00053820
08/26/2009,0.00053910
08/27/2009,0.00054020
08/28/2009,0.00054090
08/29/2009,0.00053740
08/30/2009,0.00054010
08/31/2009,0.00054010
09/01/2009,0.00053850
09/02/2009,0.00053890
09/03/2009,0.00054220
09/04/2009,0.00054130
09/05/2009,0.00054250
09/06/2009,0.00054340
09/07/2009,0.00054340
09/08/2009,0.00054170
09/09/2009,0.00053780
09/10/2009,0.0005340
09/11/2009,0.00053480
09/12/2009,0.0005310
09/13/2009,0.00053190
09/14/2009,0.00052640
09/15/2009,0.00053240
09/16/2009,0.00053060
09/17/2009,0.00052930
09/18/2009,0.0005280
09/19/2009,0.00052950
09/20/2009,0.00053060
09/21/2009,0.00053060
09/22/2009,0.00053020
09/23/2009,0.00052790
09/24/2009,0.00052910
09/25/2009,0.00053080
09/26/2009,0.0005290
09/27/2009,0.00052830
09/28/2009,0.00052830
09/29/2009,0.0005270
09/30/2009,0.00052850
10/01/2009,0.00052910
10/02/2009,0.00053220
10/03/2009,0.00053330
10/04/2009,0.0005340
10/05/2009,0.00053390
10/06/2009,0.00052940
10/07/2009,0.00052870
10/08/2009,0.00052790
10/09/2009,0.00052310
10/10/2009,0.00052520
10/11/2009,0.00052520
10/12/2009,0.00052490
10/13/2009,0.00052310
10/14/2009,0.00052040
10/15/2009,0.0005190
10/16/2009,0.0005140
10/17/2009,0.00051420"

let data_ke = "10/11/2008,0.010390
10/12/2008,0.010260
10/13/2008,0.010260
10/14/2008,0.010240
10/15/2008,0.010110
10/16/2008,0.010180
10/17/2008,0.010550
10/18/2008,0.010250
10/19/2008,0.0097590
10/20/2008,0.0097590
10/21/2008,0.010160
10/22/2008,0.010180
10/23/2008,0.010740
10/24/2008,0.010720
10/25/2008,0.010890
10/26/2008,0.010110
10/27/2008,0.010170
10/28/2008,0.0110
10/29/2008,0.010920
10/30/2008,0.010670
10/31/2008,0.010190
11/01/2008,0.010360
11/02/2008,0.010110
11/03/2008,0.01040
11/04/2008,0.01040
11/05/2008,0.011090
11/06/2008,0.011180
11/07/2008,0.011040
11/08/2008,0.011020
11/09/2008,0.010570
11/10/2008,0.010560
11/11/2008,0.010850
11/12/2008,0.010710
11/13/2008,0.010620
11/14/2008,0.010530
11/15/2008,0.010440
11/16/2008,0.010360
11/17/2008,0.010370
11/18/2008,0.010660
11/19/2008,0.010540
11/20/2008,0.010580
11/21/2008,0.010650
11/22/2008,0.010640
11/23/2008,0.010280
11/24/2008,0.010280
11/25/2008,0.010450
11/26/2008,0.01030
11/27/2008,0.010290
11/28/2008,0.010410
11/29/2008,0.010330
11/30/2008,0.01010
12/01/2008,0.01010
12/02/2008,0.010370
12/03/2008,0.010340
12/04/2008,0.010360
12/05/2008,0.010440
12/06/2008,0.010370
12/07/2008,0.010120
12/08/2008,0.010120
12/09/2008,0.010210
12/10/2008,0.010320
12/11/2008,0.010270
12/12/2008,0.010210
12/13/2008,0.010080
12/14/2008,0.0097740
12/15/2008,0.0097760
12/16/2008,0.0099810
12/17/2008,0.0098510
12/18/2008,0.0095790
12/19/2008,0.010070
12/20/2008,0.010750
12/21/2008,0.0096010
12/22/2008,0.0096010
12/23/2008,0.0099340
12/24/2008,0.0096790
12/25/2008,0.009360
12/26/2008,0.0093370
12/27/2008,0.0093090
12/28/2008,0.0093230
12/29/2008,0.0093230
12/30/2008,0.0094860
12/31/2008,0.0098910
01/01/2009,0.0091620
01/02/2009,0.0092020
01/03/2009,0.010020
01/04/2009,0.0092550
01/05/2009,0.0092560
01/06/2009,0.0095670
01/07/2009,0.0097990
01/08/2009,0.0097830
01/09/2009,0.0098610
01/10/2009,0.0098950
01/11/2009,0.0099050
01/12/2009,0.0099050
01/13/2009,0.010010
01/14/2009,0.010050
01/15/2009,0.010040
01/16/2009,0.0099890
01/17/2009,0.0099830
01/18/2009,0.009760
01/19/2009,0.0097550
01/20/2009,0.010020
01/21/2009,0.010030
01/22/2009,0.010110
01/23/2009,0.010010
01/24/2009,0.010140
01/25/2009,0.0098760
01/26/2009,0.0098760
01/27/2009,0.010090
01/28/2009,0.0099370
01/29/2009,0.0099080
01/30/2009,0.010020
01/31/2009,0.01020
02/01/2009,0.0099910
02/02/2009,0.0099940
02/03/2009,0.010260
02/04/2009,0.010210
02/05/2009,0.010080
02/06/2009,0.010260
02/07/2009,0.010250
02/08/2009,0.010010
02/09/2009,0.010010
02/10/2009,0.010120
02/11/2009,0.010220
02/12/2009,0.010260
02/13/2009,0.010220
02/14/2009,0.010190
02/15/2009,0.0099710
02/16/2009,0.0099910
02/17/2009,0.01030
02/18/2009,0.010360
02/19/2009,0.010380
02/20/2009,0.010360
02/21/2009,0.010350
02/22/2009,0.0099730
02/23/2009,0.0099770
02/24/2009,0.010220
02/25/2009,0.010250
02/26/2009,0.010250
02/27/2009,0.010310
02/28/2009,0.010340
03/01/2009,0.010090
03/02/2009,0.01010
03/03/2009,0.010320
03/04/2009,0.010260
03/05/2009,0.010380
03/06/2009,0.010310
03/07/2009,0.010370
03/08/2009,0.01010
03/09/2009,0.01010
03/10/2009,0.010290
03/11/2009,0.010250
03/12/2009,0.010210
03/13/2009,0.010150
03/14/2009,0.010120
03/15/2009,0.0098990
03/16/2009,0.0098990
03/17/2009,0.0099430
03/18/2009,0.010
03/19/2009,0.0098340
03/20/2009,0.0094640
03/21/2009,0.0094970
03/22/2009,0.0093240
03/23/2009,0.0093240
03/24/2009,0.0094850
03/25/2009,0.0095370
03/26/2009,0.0096120
03/27/2009,0.0095930
03/28/2009,0.0096930
03/29/2009,0.0095650
03/30/2009,0.0095660
03/31/2009,0.0097970
04/01/2009,0.0097570
04/02/2009,0.0098320
04/03/2009,0.0097780
04/04/2009,0.0097430
04/05/2009,0.0094630
04/06/2009,0.0094620
04/07/2009,0.0096050
04/08/2009,0.0097420
04/09/2009,0.0096620
04/10/2009,0.0098420
04/11/2009,0.0095550
04/12/2009,0.0095260
04/13/2009,0.0095260
04/14/2009,0.00950
04/15/2009,0.0097880
04/16/2009,0.0098640
04/17/2009,0.0098220
04/18/2009,0.0099850
04/19/2009,0.0097880
04/20/2009,0.0097880
04/21/2009,0.010050
04/22/2009,0.010050
04/23/2009,0.010280
04/24/2009,0.010090
04/25/2009,0.010050
04/26/2009,0.0098580
04/27/2009,0.0097790
04/28/2009,0.010070
04/29/2009,0.010150
04/30/2009,0.010040
05/01/2009,0.010010
05/02/2009,0.0096880
05/03/2009,0.0096840
05/04/2009,0.0096830
05/05/2009,0.010030
05/06/2009,0.010050
05/07/2009,0.010170
05/08/2009,0.010180
05/09/2009,0.0099430
05/10/2009,0.0096270
05/11/2009,0.0096260
05/12/2009,0.00990
05/13/2009,0.0098990
05/14/2009,0.009940
05/15/2009,0.0098170
05/16/2009,0.0098370
05/17/2009,0.0096830
05/18/2009,0.0096840
05/19/2009,0.0098480
05/20/2009,0.0098360
05/21/2009,0.0097650
05/22/2009,0.0093560
05/23/2009,0.0095980
05/24/2009,0.0095750
05/25/2009,0.0095750
05/26/2009,0.0096010
05/27/2009,0.0095720
05/28/2009,0.0095290
05/29/2009,0.0096080
05/30/2009,0.009490
05/31/2009,0.0094220
06/01/2009,0.0094220
06/02/2009,0.0090620
06/03/2009,0.00940
06/04/2009,0.0093730
06/05/2009,0.0094660
06/06/2009,0.0094510
06/07/2009,0.0093010
06/08/2009,0.0093010
06/09/2009,0.0095480
06/10/2009,0.0095380
06/11/2009,0.0095020
06/12/2009,0.0094870
06/13/2009,0.0094450
06/14/2009,0.0094720
06/15/2009,0.0094730
06/16/2009,0.0096510
06/17/2009,0.0096560
06/18/2009,0.0096510
06/19/2009,0.0093330
06/20/2009,0.0095910
06/21/2009,0.0096490
06/22/2009,0.0096480
06/23/2009,0.0096580
06/24/2009,0.0095460
06/25/2009,0.0095420
06/26/2009,0.0097150
06/27/2009,0.0095940
06/28/2009,0.0096880
06/29/2009,0.0096870
06/30/2009,0.0096220
07/01/2009,0.0096710
07/02/2009,0.0097070
07/03/2009,0.0096820
07/04/2009,0.009850
07/05/2009,0.0096250
07/06/2009,0.0096250
07/07/2009,0.0097790
07/08/2009,0.0097140
07/09/2009,0.0096940
07/10/2009,0.0096960
07/11/2009,0.0097390
07/12/2009,0.0095340
07/13/2009,0.0093280
07/14/2009,0.0096720
07/15/2009,0.0096280
07/16/2009,0.0096220
07/17/2009,0.0095650
07/18/2009,0.0095570
07/19/2009,0.0094270
07/20/2009,0.0094270
07/21/2009,0.0095350
07/22/2009,0.0095390
07/23/2009,0.0095850
07/24/2009,0.0095450
07/25/2009,0.0096440
07/26/2009,0.009390
07/27/2009,0.0093890
07/28/2009,0.0095650
07/29/2009,0.0095940
07/30/2009,0.0096550
07/31/2009,0.0096770
08/01/2009,0.0092280
08/02/2009,0.009160
08/03/2009,0.0091590
08/04/2009,0.0095370
08/05/2009,0.0094880
08/06/2009,0.0094160
08/07/2009,0.0093460
08/08/2009,0.0095330
08/09/2009,0.0093010
08/10/2009,0.00930
08/11/2009,0.0096220
08/12/2009,0.0096070
08/13/2009,0.0095450
08/14/2009,0.0095110
08/15/2009,0.0095410
08/16/2009,0.0094350
08/17/2009,0.0092680
08/18/2009,0.0096270
08/19/2009,0.0096530
08/20/2009,0.0095970
08/21/2009,0.0095130
08/22/2009,0.0095230
08/23/2009,0.0093450
08/24/2009,0.0093670
08/25/2009,0.0095230
08/26/2009,0.0095570
08/27/2009,0.0095850
08/28/2009,0.0095540
08/29/2009,0.0095190
08/30/2009,0.0093750
08/31/2009,0.0093750
09/01/2009,0.0095710
09/02/2009,0.009570
09/03/2009,0.0095980
09/04/2009,0.0094250
09/05/2009,0.0095030
09/06/2009,0.0093770
09/07/2009,0.0092430
09/08/2009,0.0093880
09/09/2009,0.0094460
09/10/2009,0.0092290
09/11/2009,0.0092850
09/12/2009,0.0092890
09/13/2009,0.0093050
09/14/2009,0.0091080
09/15/2009,0.0094160
09/16/2009,0.0092880
09/17/2009,0.0092320
09/18/2009,0.0093030
09/19/2009,0.0092820
09/20/2009,0.0092750
09/21/2009,0.0092830
09/22/2009,0.0095090
09/23/2009,0.0093030
09/24/2009,0.0092710
09/25/2009,0.0093940
09/26/2009,0.009550
09/27/2009,0.0092780
09/28/2009,0.0092350
09/29/2009,0.0094460
09/30/2009,0.0095350
10/01/2009,0.0095530
10/02/2009,0.0095260
10/03/2009,0.0095460
10/04/2009,0.0092490
10/05/2009,0.0092160
10/06/2009,0.009460
10/07/2009,0.009460
10/08/2009,0.0094830
10/09/2009,0.0094530
10/10/2009,0.0093830
10/11/2009,0.0092170
10/12/2009,0.0092170
10/13/2009,0.0093960
10/14/2009,0.0093740
10/15/2009,0.0093450
10/16/2009,0.0093170
10/17/2009,0.0093290"
